from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship

Base = declarative_base()

class User(Base):
    __tablename__ = 'users'

    id = Column(Integer, primary_key=True, index=True)
    username = Column(String, unique=True, index=True)
    userpass = Column(String)
    userlevel = Column(Integer)
    name = Column(String)
    email = Column(String)

    userinfo = relationship("Userinfo", back_populates="user")

class Userinfo(Base):
    __tablename__ = 'userinfo'

    id = Column(Integer, primary_key=True, index=True)
    userid = Column(Integer, ForeignKey('users.id'))
    name = Column(String)
    email = Column(String)

    user = relationship("User", back_populates="userinfo")